﻿<!--#include file="lib/base.asp"-->
<!--#include file="theme.asp"-->
<%

dim act:act=lcase(sdcms.fget("act",0))
select case act
	case "contact":contact()
	case else
	sdcms.echo "参数不正确"
end select

sub contact()
	dim userid,Content
	userid=sdcms.enhtml(sdcms.fpost("userid",0))
	Content=sdcms.enhtml(sdcms.fpost("Content",0))

	if sdcms.strlen(Content)<5 or  sdcms.strlen(Content)>255 then
		sdcms.ajaxjson "&#20869;&#23481;&#38271;&#24230;&#65306;&#53;&#45;&#53;&#48;&#20010;&#23383;&#31526;",0
		exit sub
	end if
	
	dim data:data=sdcms.db.dbload(1,"id","sd_user","id="&userid&"","")
	if ubound(data)<0 then
		sdcms.ajaxjson "&#29992;&#25143;&#37038;&#31665;&#19981;&#23384;&#22312;",0
		exit sub
	else
	dim toid:toid=data(0,0)
	end if
dim fromid
   if sdcms.is_login then
	dim userdata:userdata=sdcms.userinfo
	fromid=userdata(0)
	else
	fromid=0
	end if
	sdcms.createusermessage array(array("title","客户留言",50,1),array("fromid",fromid,0,0),array("userid",toid,0,0),array("content",Content,255,1),array("createdate",sqltime,0,0),array("isread",0,0,0))
	
	sdcms.sendmail userdata(3),"您有一条新客户留言",Content
		
	sdcms.ajaxjson "&#28040;&#24687;&#21457;&#36865;&#25104;&#21151;",1
end sub
sdcms.db.dbclose
%>